package redis

import (
	"fmt"
	"github.com/go-redis/redis"
	"tiktok/app_config"
)

var Rdb *redis.Client

func GetRedis() {
	var app = app_config.InitConfig.RedisConfig
	client := redis.NewClient(&redis.Options{
		Addr:     app.Addr,
		Password: app.Password, // no password set
		DB:       app.Db,       // use default DB
	})

	_, err := client.Ping().Result()
	if err != nil {
		fmt.Println("Redis数据库连接失败")
		return
	}
	fmt.Println("Redis数据库连接成功")
	//fmt.Println(pong, err)
	// Output: PONG <nil>
}
